Read IMU raw data

Read IMU raw data1.IMU Introduction2.IMU principle3.Brief analysis of IMU driver codeExperimental effect

1.IMU Introduction

The IMU used on the board is the ICM-20607 model, which is the upgraded version of MPU6050. However, compared with MPU6050, it lacks the function of four-element conversion of Euler angle. You need to write this part of function yourself. This tutorial does not provide the functions of this part. Interested students can learn from CSDN by themselves. ICM-20607: gyroscope included in it is used to measure angular velocity; Accelerometer, used to measure linear velocity.

2.IMU principle

According to the manual and schematic diagram image-2023022700001 The following results can be obtained:

  1. IMU can be controlled by I2C protocol or SPI protocol, but the schematic diagram shows that it can only be controlled by I2C, and this experiment uses the communication mode of software I2C.
  2. The accelerometers and gyroscopes of the IMU on board are set with corresponding ranges through register configuration.
  3. The I2C address of IMU is related to the level of AD0 pin. The address of AD0=0: I2C is 0x68, and the address of AD0=1: I2C is 0x69

3.Brief analysis of IMU driver code

It can be seen from the initialization function that the I2C interface of the communication is initialized first, and then the IMU is detected whether it is online, and its register is initialized when it is online

When the initialization is successful, enter the data reading

Available according to code

  1. Because the IMU has been powered on for a period of time with zero point drift, the data is inaccurate, so the data in this period is removed.
  2. After waiting for a period of time, the data changes in a range, indicating that the data is stable, but it needs to be corrected, so it needs a period of time to get the data for correction, that is, the code in if.
  3. After the correction is completed, the data of the accelerometer or gyroscope is basically unchanged when it is still.
  4. When the board moves, the accelerometer for measuring linear velocity and the gyroscope for measuring angular velocity will change.

Experimental effect

1.When it is detected that the IMU is not online, please press the reset key and power off to restart. The effect is as shown in the figure: image-2023022700002

2.When the IMU is detected online and communicated, the LCD screen will display the accelerometer data, as shown in the figure: image-2023022700003 Note: If you see gyroscope or accelerometer and the prohibited data is not 0, please enter bsp in the project file_ In icm20607. c, modify (295-301). No line represents the x, y, and z values of each range meter. For example, the Z axis of the accelerometer in the above figure is - 7. Then add "+7" in line 301 and download the program again. This is mainly because each board is not welded well. The modification is shown in the figure Before modification: image-2023022700004 After change: image-2023022700005

3.However, when the IMU moves, the data will change constantly and be displayed on the LCD screen.